﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class CTHDBanLeBlo
    {
        #region "Khai báo các biến"
        private CTHDBanLeDAO da;
        private CTHDBanLeDTO _CTHDBL;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTHDBanLeDTO CTHDBL
        {
            get { return _CTHDBL; }
            set { _CTHDBL = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public CTHDBanLeBlo()
        {
            _CTHDBL = new CTHDBanLeDTO();
            da = new CTHDBanLeDAO();
        }
        public bool InsertCTHDBL(string MaMH, string MaHDBL, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            CTHDBL = new CTHDBanLeDTO(MaMH, MaHDBL, DonGia, SoLuong, ChietKhau, ThanhTien);
            if (!da.InsertCTHDBL(CTHDBL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTHDBL(string MaMH, string MaHDBL, double DonGia, int SoLuong, float ChietKhau, double ThanhTien)
        {
            CTHDBL = new CTHDBanLeDTO(MaMH, MaHDBL, DonGia, SoLuong, ChietKhau, ThanhTien);
            if (!da.UpdateCTHDBL(CTHDBL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTHDBL(string MaMH,string MaHDBL)
        {
            if (!da.DeleteCTHDBL(MaMH,MaHDBL))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTHDBanLe()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTHDBanLe();
            return ds;
        }
        #endregion
    }
}